<?php

namespace App\Repository\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Prettus\Repository\Contracts\Transformable;
use Prettus\Repository\Traits\TransformableTrait;

/**
 * Class Carts.
 *
 * @package namespace App\Repository\Models;
 */
class Carts extends Model implements Transformable
{
    use TransformableTrait;
    use SoftDeletes;

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = ['id','user_id', 'shop_id', 'product_id', 'sku_id', 'num', 'status'];

    //购物车添加上限
    const CART_UPPER_LIMIT = 100;

    const STATUS_VALID = 1;
    const STATUS_INVALID = 0;

    public function product(){
        return $this->hasOne(Products::class, 'id', 'product_id');
    }

    public function sku(){
        return $this->hasOne(ProductSkus::class, 'id', 'sku_id');
    }

}
